package com.base.cn.platform.os.controller.op.groom;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.common.log.aop.AdminModuleEnum;
import com.base.cn.platform.os.common.log.aop.OpLog;
import com.base.cn.platform.os.service.manage.op.groom.OpGroomDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 推荐位置
 * @author ll
 * @date 2018/5/18 15:54
 */
@Controller
@RequestMapping("/admin/op/groom")
public class AdminOpGroomDataController extends AdminBaseController {

    @Autowired
    private OpGroomDataService opGroomDataService;


    /**
     * 批量添加推荐
     * @param dataIds 推荐数据Id
     * @param dataType 推荐类型
     * @param placeIds 推荐位置Id
     * @return
     */
    @RequestMapping("/saveOpGroomDataBatch")
    @ResponseBody
    @OpLog(module = AdminModuleEnum.OTHER, action = "批量添加推荐数据")
    public Map<String,Object> saveOpGroomDataBatch(@RequestParam("dataIds")String dataIds,
                                                   @RequestParam("dataType")String dataType,
                                                   @RequestParam("placeIds")String placeIds){
        return opGroomDataService.savePlaceDataBatch(dataIds,dataType,placeIds);
    }


    /**
     * 单个推荐位置添加推荐数据
     * @param dataIds
     * @param dataType
     * @param placeKey
     * @param groomNum
     * @return
     */
    @RequestMapping("/saveUpdateOpGroomData")
    @ResponseBody
    @OpLog(module = AdminModuleEnum.OTHER, action = "单个推荐位置添加推荐数据")
    public Map<String,Object> saveUpdateOpGroomData(@RequestParam("dataIds")String dataIds,
                                                    @RequestParam("dataType")String dataType,
                                                    @RequestParam("placeKey")String placeKey,
                                                    @RequestParam("groomNum")Integer groomNum,
                                                    @RequestParam("dataSorts")String dataSorts){
        return opGroomDataService.saveUpdateOpGroomData(dataIds,dataType,placeKey,groomNum,dataSorts);
    }


    /**
     * 清空推荐位置
     * @param dataType  推荐类型
     * @param placeKey  推荐Key
     * @return
     */
    @RequestMapping("/deleteGroomData")
    @ResponseBody
    @OpLog(module = AdminModuleEnum.OTHER, action = "清空推荐位置数据")
    public Map<String,Object> deleteGroomData(@RequestParam("dataType")String dataType,
                                              @RequestParam("placeKey")String placeKey){
        return opGroomDataService.deleteGroomData(dataType,placeKey);
    }
}
